from strategy.models import Strategy, CreditGlobalAction, StrategyGlobalAction, SafetyCreditEvaluation
from strategy.migrations import strategy_list, credit_global_list, global_strategy_list, safety_credit_list
from django.core.exceptions import ValidationError
from django.core.management.base import BaseCommand
from django.db import transaction
from asset.models import DeviceInfo
from mongolog.models import AppsLog


class Command(BaseCommand):
    help = '填充默认策略'

    def add_arguments(self, parser):
        pass

    @transaction.atomic()
    def handle(self, *args, **options):
        Strategy.objects.all().delete()
        Strategy.objects.bulk_create(strategy_list)
        # CreditGlobalAction.objects.all().delete()
        # StrategyGlobalAction.objects.all().delete()
        # CreditGlobalAction.objects.bulk_create(credit_global_list)
        # StrategyGlobalAction.objects.bulk_create(global_strategy_list)
        # SafetyCreditEvaluation.objects.all().delete()
        # SafetyCreditEvaluation.objects.bulk_create(safety_credit_list)
        print("Done")

